package com.archgeek.spark.examples.v20210223

import org.apache.spark.SparkConf
import org.apache.spark.sql.{Encoders, SparkSession}
import org.apache.spark.sql.types.StructType

import scala.beans.BeanProperty

/**
 *
 *
 * Create by pizhihui on 2021-02-23
 */

class Person {
  @BeanProperty
  var name: String = ""
  @BeanProperty
  var age: Int = 0
}

object SparkSqlDemo {

  def main(args: Array[String]): Unit = {


    import scala.io.StdIn._


    val conf = new SparkConf()
    val session = SparkSession.builder()
      .config(conf)
      .getOrCreate()


    val df = session.read.json("/data")

    df.createTempView("ooxx")




    while (true) {
      val sql = readLine("input your sql:")
      session.sql(sql).show
    }

  }

}
